<template>
	<view class="order-pages">
		<fixed>
			<!-- <tab @change="handerTabChange" :list="tabList" :activeIndex="activeIndex*1" :activeColor="primaryColor"
				:width="100/tabList.length + '%'" height="100rpx"></tab>
			<view class="b-1px-b"></view> -->
		</fixed>

		<view v-if="activeIndex == 0 || activeIndex == 1 || activeIndex == 4" @tap.stop="goDetail(index,item,'detail')" class="flex-center mt-sm item-child mt-sm ml-md mr-md pd-sm fill-base radius-16"
			v-for="(item,index) in list" :key="index">
			<image mode="aspectFill" class="cover radius" style="width: 100rpx; height: 100rpx;" :src="item.avatar_thumb"></image>
			
			<view class="flex-1 ml-md">
				<view class="flex-y-baseline mb-md">
					<view class="f-title c-title text-bold max-400 ellipsis">
						{{item.user_nicename}}
					</view>
					<view class="flex flex-center pl-sm">
						<image v-if="item.sex == 0" mode="aspectFill" class="cover radius mr-sm" style="width: 30rpx; height: 30rpx;" src="../static/common/icon_sex_female_1.png"></image>
						<image v-else mode="aspectFill" class="cover radius mr-sm" style="width: 30rpx; height: 30rpx;" src="../static/common/icon_sex_male_1.png"></image>
						<image mode="aspectFill" class="cover radius mr-sm" style="width: 60rpx; height: 30rpx;" src="http://qiniu.10-yuan.com/new_new_level_anchor_0.png"></image>
						
					</view>
					<view class="msgnoread" v-if="item.noread_num>0">{{item.noread_num}}</view>
				</view>

				<view class="flex-y-center f-caption c-caption">{{item.signature}}</view>
			</view>
		</view>
		
		<view v-if="activeIndex == 2" @tap.stop="goDetail(index,item,'detail')" class="flex-center mt-sm item-child mt-sm ml-md mr-md pd-sm fill-base radius-16"
			v-for="(item,index) in list" :key="index">
			<image mode="aspectFill" class="cover radius" style="width: 100rpx; height: 100rpx;" src="/static/logo.png"></image>
			<view class="flex-1 ml-md">
				<view class="flex-y-baseline mb-md">
					<view class="f-title c-title text-bold max-400 ellipsis">
						系统通知{{}}
					</view>
				</view>
		
				<view class="flex-y-center f-caption c-caption">{{item.content}}</view>
			</view>
		</view>
		
		<view v-if="activeIndex == 3" @tap.stop="goDetail(index,item,'detail')" class="flex-center mt-sm item-child mt-sm ml-md mr-md pd-sm fill-base radius-16"
			v-for="(item,index) in list" :key="index">
			<image mode="aspectFill" class="cover radius" style="width: 100rpx; height: 100rpx;" :src="item.userinfo.avatar_thumb"></image>
			<view class="msgnoread" v-if="item.noread_num">{{item.noread_num}}</view>
			<view class="flex-1 ml-md">
				<view class="flex-y-baseline mb-md">
					<view class="f-title c-title text-bold max-400 ellipsis">
						{{item.userinfo.user_nicename}}
					</view>
					<view class="flex flex-center pl-sm">
						<image v-if="item.userinfo.sex == 0" mode="aspectFill" class="cover radius mr-sm" style="width: 30rpx; height: 30rpx;" src="../static/common/icon_sex_female_1.png"></image>
						<image v-else mode="aspectFill" class="cover radius mr-sm" style="width: 30rpx; height: 30rpx;" src="../static/common/icon_sex_male_1.png"></image>
						
						<image mode="aspectFill" class="cover radius mr-sm" style="width: 60rpx; height: 30rpx;" src="http://qiniu.10-yuan.com/new_new_level_anchor_0.png"></image>
						
					</view>
					
				</view>
		
				<view class="flex-y-center f-caption c-caption">{{item.userinfo.signature}}</view>
			</view>
			<view class="flex-y-center f-caption c-caption mr-md">{{item.distance}}</view>
		</view>
		
		<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
		</load-more>
		<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>

		<view class="space-footer"></view>

		<view :style="{height: `${configInfo.tabbarHeight}px`}"></view>
		<tabbar :cur="2"></tabbar>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from "vuex"
	import tabbar from "@/components/tabbar.vue"
	import $api from '@/api/index.js';
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				options: {},
				loading: true,
				pageActive: false,
				activeIndex: 0,
				tabList: [
					{
						title: '在线',
						id: 0
					}, {
						title: '新人',
						id: 1,
						// number: 10
					}, {
						title: '全部',
						id: 5
					}, {
						title: '附近',
						id: 6
					}, {
						title: '单身',
						id: 7
					}
					// , {
					// 	title: '免费活动',
					// 	id: 7
					// }
				],
				list: [],
				carList: {},
				haveOperItem: false
			}
		},
		computed: mapState({
			primaryColor: state => state.config.configInfo.primaryColor,
			subColor: state => state.config.configInfo.subColor,
			configInfo: state => state.config.configInfo,
			userInfo: state => state.user.userInfo,
		}),
		async onLoad(options) {
			this.activeIndex=2
			await this.initIndex()
		},
		onPullDownRefresh() {
			this.initRefresh();
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.loading) return;
			this.loading = true;
			this.getList();
		},
		methods: {
			...mapActions(['getConfigInfo']),
			async initIndex(refresh = false) {
				await this.getList(1)
				this.$util.setNavigationBarColor({
					bg: this.primaryColor
				})
			},
			initRefresh() {
				this.initIndex(true)
			},
			
			async getList() {
				this.getNewOnlineList()
			},
			async getNewOnlineList() {
				this.loading = true
				
				let param= {
					p: 1,
				}
				
				let data = [];
				
				if(this.activeIndex == 0){
					data = await this.$api.service.getNewOnlineList(param)
				} else if(this.activeIndex == 1){
					data = await this.$api.service.getNewRegisteredList(param)
				} else if(this.activeIndex == 2){
					data = await this.$api.service.getMessageGetList(param)
				} else if(this.activeIndex == 3){
					param['lng'] = this.userInfo.lng
					param['lat'] = this.userInfo.lat
					data = await this.$api.service.getNearbypeople(param)
				} else if(this.activeIndex == 4){
					param['type'] = '老师'
					data = await this.$api.service.getconditionuser(param)
				}
				
				this.list = data
				
				this.loading = false
				this.$util.hideAll()
			},
			handerTabChange(index) {
				this.activeIndex = index
				uni.pageScrollTo({
					scrollTop: 0
				})
				this.$util.showLoading()
				this.getList()
			},
			// 订单详情/申请退款/去评价
			goDetail(index,item, page) {
				let {
					id
				} = this.list[index]
				let url = `/user/pages/user-detail?id=${id}&from=mes`
				if(item.is_pay == 1){
					url = `/pages/chartDeatil?id=${id}&from=mes`
				}
				
				this.$util.goUrl({
					url
				})
			}
		}
	}
</script>


<style lang="scss">
	.list-item2 {
		float: left;
		box-sizing: border-box;
		width: 45%;
		height: 400rpx;
		padding: 10px 6px;
		
		background-position: center;
		background-size:cover;
		background-repeat: no-repeat;
		
		.member-tag {
			width: 168rpx;
			height: 46rpx;
			background: #0e0f0f;
		
			.iconfont {
				font-size: 28rpx;
			}
		}
		
		.cover {
			width: 180rpx;
			height: 180rpx;
		}
		
		.text {
			width: 75rpx;
			height: 75rpx;
		}
	
		.text-delete {
			font-size: 20rpx;
			color: #B9B9B9;
		}
	
		.item-btn {
			width: 130rpx;
			height: 52rpx;
			border-radius: 8rpx;
		}
	}
	.msgnoread{
		background-color: red;
		color: #fff;
		padding: 2px;
		padding-left: 4px;
		border-radius: 25px;
		width:15px;
		height: 18px;
		z-index: 9999;
	}
</style>
